package bancosys.tec.persist.dao;

import java.io.Serializable;

import jmine.tec.annotations.Unmodifiable;
import jmine.tec.persist.PersistMessages;
import bancosys.tec.persist.Persistable;

/**
 * Classe base para os DAOS de dados basicos, que deveriam existir sempre. Reescreve metodos de BaseDAO capturando BeanNotFound e lancando
 * excecao Runtime caso nao encontre.
 * 
 * @param <BoClass> classe gerenciada pelo DAO.
 * @created Fev 22, 2007
 * @author Marcio Ribeiro (mmr)
 */
@Unmodifiable
public abstract class BasicDataDAO<BoClass extends Persistable> extends BaseDAO<BoClass> {
    /**
     * Busca elemento por primary key capturando BeanNotFoundException e lancando BasicDataBeanNotFoundException.
     * 
     * @param pk primary key.
     * @return o elemento com a primary key passada.
     */
    @Override
    public BoClass findByPk(Serializable pk) {
        try {
            return super.findByPk(pk);
        } catch (BeanNotFoundException e) {
            throw new BasicDataBeanNotFoundException(PersistMessages.BASIC_DATA_NOT_FOUND.create(this.getPersistableClass().getName(), pk));
        }
    }
}